package net.yihang.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

@Aspect
public class AroundAspect {

    @Around("within(net.yihang.service.TargetService)")
    public Object invoke(ProceedingJoinPoint pjp) throws Throwable{
        try {
            System.out.println("[aop before...]");
            Object result = pjp.proceed();
            System.out.println("[aop after returning...]");
            return result;
        } catch (Throwable e) {
            System.out.println("[aop after throwing...]");
            throw e;
        } finally {
            System.out.println("[aop after...]");
        }
    }
}
